<?php

namespace backend\controllers;

use backend\models\Baselogger;
use backend\models\Basemodule;
use yii;

class LoggerController extends CommonController
{
    public function actionIndex()
    {
        $moduleId = yii::$app->request->get('moduleId');
        $module = Basemodule::findOne(['Id' => $moduleId]);
        if (yii::$app->request->isPost){
            $post = yii::$app->request->post();
            $pageCurrent = $post['pageCurrent'];
            $pageSize = $post['pageSize'];
            $logger = new Baselogger();
            $datas = $logger->getLogData($post, $pageCurrent, $pageSize);
            return $this->renderJson($datas);
        }
        $citem = Basemodule::getMoreRole($this->roleId, $moduleId);
        $data = [
            'module' => $module,
            'citem' => $citem
        ];
        return $this->renderPartial('index',$data);
    }


    public function actionHandler()
    {
        if (yii::$app->request->isPost){
            $data = yii::$app->request->post();
            $logger = new Baselogger();
            $result = $logger->deleteData($data);
            return $this->renderJson($result);
        }
    }

}
